<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="jquery-1.12.3.min.js"></script>
	<style>
		*{
			margin: 0;
			padding: 0;
		}
		div{
			width: 200px;
			height: 200px;
			background-color: green;
			margin-bottom: 10px;
		}
		.active{
			border:5px solid red;
		}
	</style>
</head>
<body>
	<div></div>
	<div></div>
	<div></div>
	<div></div>
	<div></div>
	<button>统计选中</button>

	<script>
	$(function(){
		$("div").click(function(){
			$(this).toggleClass("active");
		})
		$("button").click(function(){
			var sum=0;
			$("div").each(function(index,element){
				if ($(element).hasClass("active")) {
					sum++;
				}
			})
			alert(sum)
		})
	})
	</script>
</body>
</html>